<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
    <title>form-countval</title>
    <link rel="stylesheet" href="../scripts/lib/seedsui/seedsui.min.css">
</head>

<body ontouchstart="">
    <header>
        <div class="titlebar">
            <a href="javascript:back()" class="titlebar-button titlebar-left">
                <button class="button radius4 grayscale" style="height:32px;line-height:32px;padding:0 8px;">取消</button>
            </a>
            <h1 class="titlebar-title text-center">文字计数</h1>
            <a class="titlebar-button titlebar-right">
                <button class="button radius4 warn" style="height:32px;line-height:32px;padding:0 8px;">发布</button>
            </a>
        </div>
    </header>
    <article>
        <div class="group" style="padding:0 8px;">
            <div class="inputbox underline">
                <input type="text" class="countvalue input-text" data-maxlength="10" placeholder="请输入标题"/>
                <p></p>
            </div>
            <div class="inputbox">
                <textarea class="countvalue input-textarea" data-maxlength="30" placeholder="请输入评论信息"></textarea>
                <p class="absolute" style="bottom: 10px;right:10px;"></p>
            </div>
        </div>
    </article>

    <script src="../scripts/lib/seedsui/seedsui.min.js"></script>
    <!--Exmobi能力-->
    <!-- <script src="../scripts/lib/exmobi/exmobi.js"></script> -->
    <script>
        var view={
            /*=========================
              Model
              ===========================*/
            render:function(){
                var self = this;
                //渲染页面
                this.countValues=new CountValues({
                    onInput:function(e){
                        //console.log("输入中");
                    },
                    onInputOut:function(e){
                        //console.log("超过数字限制时");
                        var input=e.target;
                        input.nextElementSibling.innerHTML=Math.round(e.maxLength-input.value.length);
                        input.nextElementSibling.classList.add("color-tip");
                    },
                    onInputIn:function(e){
                        //console.log("没有超过数字限制时");
                        var input=e.target;
                        input.nextElementSibling.innerHTML="";
                        input.nextElementSibling.classList.remove("color-tip");
                    }
                });
                
                //加载数据
                this.loadData();
            },
            refresh:function(){
                console.log("刷新");
            },
            destroy:function(){
                console.log("移除");
            },
            loadData:function(){

                this._attach();//使用backbone时，此行无用
            },

            /*=========================
              Method
              ===========================*/
            _method:function(){
            },
            
            /*=========================
              Events
              ===========================*/
            _attach:function(e){
                var self=this;
            },

            /*=========================
              Event Handler
              ===========================*/
            _onEvent:function(e){
                
            }
        }

        window.addEventListener("load",function(){
            view.render();
        }, false);

        //定义exmobi返回
        function back(){history.go(-1)}
    </script>
</body>
</html>